Skip to content

assertion/rewrite: fix test crash on assert failure with terminalreporter disabled#14418

Merged
bluetech merged 2 commits into
pytest-dev:mainfrom
bluetech:assert-no-terminalreporter
May 1, 2026
Merged

assertion/rewrite: fix test crash on assert failure with terminalreporter disabled#14418
bluetech merged 2 commits into
pytest-dev:mainfrom
bluetech:assert-no-terminalreporter

Conversation

@bluetech

Copy link
Copy Markdown
Member

Based on #14383. Replaces #14378 (see there for some context).

The config.get_terminal_writer() in assertrepr_compare (=> the function injected by assertion rewriting for every assert) requires the terminalreporter plugin, so it crashed when the plugin is disabled.

Fix #14377.

@bluetech bluetech force-pushed the assert-no-terminalreporter branch from d84e6e3 to 54f8638 Compare April 25, 2026 18:55
@psf-chronographer psf-chronographer Bot added the bot:chronographer:provided (automation) changelog entry is part of PR label Apr 25, 2026

@nicoddemus nicoddemus left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

bluetech added 2 commits May 1, 2026 10:32
Seems better to make the lower-level function more agnostic.
…orter` disabled

The `config.get_terminal_writer()` in `assertrepr_compare` (=> the
function injected by assertion rewriting for every `assert`) requires
the `terminalreporter` plugin, so it crashed when the plugin is
disabled.

Fix pytest-dev#14377.
@bluetech bluetech force-pushed the assert-no-terminalreporter branch from 54f8638 to 4ee157d Compare May 1, 2026 07:32
@bluetech bluetech enabled auto-merge May 1, 2026 07:33
@bluetech bluetech merged commit 32dab33 into pytest-dev:main May 1, 2026
33 checks passed
@bluetech bluetech deleted the assert-no-terminalreporter branch May 1, 2026 07:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:chronographer:provided (automation) changelog entry is part of PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Config.get_terminal_writer() crashes with AssertionError when terminalreporter is unregistered (pytest-tap streaming + non-test file asserts)

2 participants